#ifndef _BALANCE_CMD_HPP_20120612
#define _BALANCE_CMD_HPP_20120612

#include <string>
#include <stdint.h>

#include "streamer.hpp"

#include "cmd_type.hpp"
#include "cmd_value.hpp"
#include "cmd_comm.hpp"

using namespace mina;

namespace cmd 
{
	struct SSReportLoadReq : public SSHead
	{
		public :
			uint64_t  _ip;
			uint32_t  _port;
			uint16_t  _load;

		public :
			SSReportLoadReq()
				: SSHead(BALANCE_CMD_0, SS_REPORT_LOAD_REQ),
				  _ip(0), _port(0), _load(0)
			{
			}

			uint32_t size() const
			{
				return (SSHead::size() + sizeof(_ip) + sizeof(_port) + sizeof(_load));
			}

			void serialize(Streamer & streamer);

			const std::string to_string() const;
	};

	struct SSReportLoadRes : public SSHead
	{
		public :
			SSReportLoadRes()
				: SSHead(BALANCE_CMD_0, SS_REPORT_LOAD_RES)
			{
			}
	};

	struct CSGetMinLoadReq : public CSHead
	{
		public :
			CSGetMinLoadReq()
				: CSHead(BALANCE_CMD_0, CS_GET_MIN_LOAD_REQ)
			{
			}
	};

	struct SCGetMinLoadRes : public SCHead
	{
		public :
			uint64_t _ip;
			uint32_t _port;

		public :
			SCGetMinLoadRes()
				: SCHead(BALANCE_CMD_0, SC_GET_MIN_LOAD_RES),
				  _ip(0), _port(0)
			{
			}

			uint32_t size() const
			{
				uint32_t ret = SCHead::size() + sizeof(_err_code);

				if (0 != _err_code)
				{
					return ret;
				}

				return (ret + sizeof(_ip) + sizeof(_port));
			}

			void serialize(Streamer & streamer);

			const std::string to_string() const;
	};
};

#endif

